package com.example.study.design.strategy;

import com.example.study.model.Goods;

import java.util.Objects;

/**
 * 策略上下文(策略接口持有者)
 *
 * @author duckquan
 */
public class GoodsStrategyContext {

    private GoodsHandleStrategy goodsHandleStrategy;

    public void setGoodsHandleStrategy(GoodsHandleStrategy goodsHandleStrategy) {
        this.goodsHandleStrategy = goodsHandleStrategy;
    }

    public Goods handleGoods(Goods goods) {
        if (Objects.isNull(goodsHandleStrategy)) {
            return null;
        }
        return goodsHandleStrategy.handleGoods(goods);
    }

}
